package com.movitech.mobile.cz.base.purchase.bizcontroller;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.movitech.mobile.cz.base.common.aop.ServiceThrowable;
import com.movitech.mobile.cz.base.common.util.CommonConstants;
import com.movitech.mobile.cz.base.common.util.DateUtils;
import com.movitech.mobile.cz.base.common.util.StringUtils;
import com.movitech.mobile.cz.base.modules.controller.RestReturnResult;
import com.movitech.mobile.cz.base.purchase.bizservice.WorkFlowService;
import com.movitech.mobile.cz.base.purchase.bizvo.*;
import com.movitech.mobile.cz.base.purchase.bizvo.purchase.NodeClickVo;
import com.movitech.mobile.cz.base.purchase.bizvo.purchase.TechnicaBidScoreReqVO;
import com.movitech.mobile.cz.base.purchase.bizvo.purchase.UpdateOperatorVO;
import com.movitech.mobile.cz.base.purchase.entity.*;
import com.movitech.mobile.cz.base.purchase.entity.ext.*;
import com.movitech.mobile.cz.base.purchase.service.*;
import com.movitech.mobile.cz.base.sessionuser.SessionUserVo;
import com.movitech.mobile.cz.base.supplier.bizvo.FlowTurnVO;
import com.movitech.mobile.cz.base.supplier.bizvo.PurchaseMbsCallBackVO;
import com.movitech.mobile.cz.base.supplier.entity.SMyDeals;
import com.movitech.mobile.cz.base.sys.entity.SAttachment;
import com.movitech.mobile.cz.base.sys.entity.SCompany;
import com.movitech.mobile.cz.base.sys.service.SAttachmentService;
import com.movitech.mobile.cz.base.sys.service.SCompanyService;
import com.movitech.mobile.cz.base.util.UserUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;

@RestController
@RequestMapping("/v1/formflow")
@Api(value = "采购流程接口", description = "采购流程接口")
public class WorkFlowController {
    @Autowired
    private WFlowFormHistoryPriceService wFlowFormHistoryPriceService;
    @Autowired
    private WFlowFormBidCandidateUnitService wFlowFormBidCandidateUnitService;
    @Autowired
    private WFlowFormPurchaseTeamService wFlowFormPurchaseTeamService;
    @Autowired
    private SAttachmentService sAttachmentService;
    @Autowired
    private WorkFlowService workFlowService;

    @Autowired
    private WFlowFormService wFlowFormService;
    @Autowired
    private WFlowFormAddendumReferersService wFlowFormAddendumReferersService;
    @Autowired
    private WFlowFormQaCountSignService wFlowFormQaCountSignService;
    @Autowired
    private SCompanyService sCompanyService;

    @PostMapping("/mbsCallBack/test")
    @ApiOperation(
            value = "模拟审批结果",
            notes = "模拟审批结果"
    )
    public RestReturnResult test(@RequestBody PurchaseMbsCallBackVO vo) {
        RestReturnResult restResult = RestReturnResult.success();
        workFlowService.purchaseMbsCallBack(vo);
        return restResult;
    }

    @GetMapping("/searchNodeList/{formId}")
    @ApiOperation(
            value = "获取节点集合",
            notes = "获取节点集合"
    )
    public RestReturnResult<HeaderVO> searchNodeList(@ApiParam(value = "表单ID", required = true) @PathVariable String formId) {
        RestReturnResult restResult = RestReturnResult.success();
        restResult.setData(workFlowService.selectHeaderList(formId));
        return restResult;
    }


    @PostMapping("/searchList")
    @ApiOperation(
            value = "采购列表查询接口",
            notes = "采购列表查询接口"
    )
    public RestReturnResult<Page<ExtWFlowForm>> searchList(@ApiParam(value = "采购列表参数", required = true) @RequestBody PurchaseListParamVo purchaseListParamVo) {
        RestReturnResult restResult = RestReturnResult.success();
        Page<ExtWFlowForm> page = new Page<>();
        page.setCurrent(purchaseListParamVo.getPageRequestVO().getPageNumber());
        page.setSize(purchaseListParamVo.getPageRequestVO().getPageSize());
        page = workFlowService.findWorkFlowList(page, purchaseListParamVo.getFlowFormListReqVO());
        restResult.setData(page);
        return restResult;
    }

    @PostMapping("/searchList/simple")
    @ApiOperation(
            value = "首页招标项目列表",
            notes = "首页招标项目列表"
    )
    public RestReturnResult<Page<ExtWFlowForm>> searchSimList(@ApiParam(value = "采购列表参数", required = true) @RequestBody PurchaseListParamVo purchaseListParamVo) {
        RestReturnResult restResult = RestReturnResult.success();
        Page<ExtWFlowForm> page = new Page<>();
        page.setCurrent(purchaseListParamVo.getPageRequestVO().getPageNumber());
        page.setSize(purchaseListParamVo.getPageRequestVO().getPageSize());
        page = workFlowService.findSimWorkFlowList(page, purchaseListParamVo.getFlowFormListReqVO());
        restResult.setData(page);
        return restResult;
    }

    @PostMapping("/selectDeals")
    @ApiOperation(
            value = "代办查询",
            notes = "代办查询"
    )
    public RestReturnResult<SMyDeals> selectDeals(@ApiParam(value = "代办查询入参", required = true) @RequestBody NodeClickVo vo) {
        RestReturnResult restResult = RestReturnResult.success();
        restResult.setData(workFlowService.selectDeals(vo));
        return restResult;
    }

    @GetMapping("/delete/{id}")
    @ApiOperation(
            value = "删除采购列表",
            notes = "删除采购列表",
            response = RestReturnResult.class
    )
    public RestReturnResult delete(@ApiParam(value = "采购列表ID", required = true) @PathVariable String id) {
        RestReturnResult restResult = RestReturnResult.success();
        workFlowService.deleteById(id);
        return restResult;
    }

    @PostMapping("/generateFlowForm")
    @ApiOperation(value = "启动采购接口", notes = "启动采购接口")
    public RestReturnResult generateFlowFormgenerateFlowForm(@ApiParam(value = "启动采购入参", required = true) @RequestBody PurchaseFlowFormBisReqVO vo) {
        RestReturnResult restResult = RestReturnResult.success();
        workFlowService.generateFlowForm(vo);
        return restResult;
    }

    @PostMapping("/associateContract")
    @ApiOperation(value = "关联合约", notes = "关联合约")
    public RestReturnResult associateContract(@RequestBody AssociateContractVO form) {
        try {
            RestReturnResult restResult = RestReturnResult.success();
            workFlowService.associateContract(form);
            return restResult;
        } catch (Exception ex) {
            RestReturnResult restResult = RestReturnResult.error();
            restResult.setMsg(ex.getMessage());
            return restResult;
        }
    }

    @PostMapping("/releaseContract")
    @ApiOperation(value = "释放合约", notes = "释放合约")
    public RestReturnResult releaseContract(@RequestBody AssociateContractVO form) {
        try {
            RestReturnResult restResult = RestReturnResult.success();
            workFlowService.releaseContract(form);
            return restResult;
        } catch (Exception ex) {
            RestReturnResult restResult = RestReturnResult.error();
            restResult.setMsg(ex.getMessage());
            return restResult;
        }
    }

    @PostMapping("/deleteContract")
    @ApiOperation(value = "删除合约", notes = "删除合约")
    public RestReturnResult deleteContract(@RequestBody AssociateContractVO form) {
        try {
            RestReturnResult restResult = RestReturnResult.success();
            workFlowService.deleteContract(form);
            return restResult;
        } catch (Exception ex) {
            RestReturnResult restResult = RestReturnResult.error();
            restResult.setMsg(ex.getMessage());
            return restResult;
        }
    }


    @GetMapping("/purchasePlanAllData/{wflowFormId}")
    @ApiOperation(value = "采购方案详情", notes = "采购方案大节点数据流", response = PurchasePlanNodeAllDataResVO.class)
    public RestReturnResult<PurchasePlanNodeAllDataResVO> purchasePlanAllData(@PathVariable("wflowFormId") String wflowFormId) {
        RestReturnResult restResult = RestReturnResult.success();
        PurchasePlanNodeAllDataResVO vo = workFlowService.selectPurchasePlanNodeData(wflowFormId);
        restResult.setData(vo);
        return restResult;
    }


    @GetMapping("/getBackBidInfoList")
    @ApiOperation(value = "回标节点信息", notes = "回标节点信息(包括二轮回标)", response = BackBidRspVO.class)
    public RestReturnResult<BackBidRspVO> getBackBidInfoList(@ApiParam(value = "表单ID", required = true) @RequestParam String flowFormId,
                                                             @ApiParam(value = "(1|2 回标OR二轮回标)", required = true) @RequestParam Integer round) {
        RestReturnResult restResult = RestReturnResult.success();
        restResult.setData(workFlowService.selectBackBidNodeData(flowFormId, round));
        return restResult;
    }


    @PostMapping("/oneThingAndOneDiscussion/history")
    @ApiOperation(value = "一事一议历史", notes = "一事一议历史", response = ExtWFlowFormDiscussionHistory.class)
    public RestReturnResult<List<ExtWFlowFormDiscussionHistory>> oneThingAndOneDiscussion(@ApiParam(value = "一事一议查询条件VO", required = true) @RequestBody WFlowFormDiscussionHistory wFlowFormDiscussionHistory) {
        RestReturnResult restResult = RestReturnResult.success();
        restResult.setData(workFlowService.getOneThingAndOneDiscussionData(wFlowFormDiscussionHistory));
        return restResult;
    }

    @PostMapping("/oneThingAndOneDiscussion/submit")
    @ApiOperation(value = "一事一议提交", notes = "一事一议")
    public RestReturnResult submitOneThingAndOneDiscussion(@ApiParam(value = "一事一议", required = true) @RequestBody ExtWFlowFormDiscussionHistory wFlowFormDiscussionHistory) {
        RestReturnResult restResult = RestReturnResult.success();
        workFlowService.submitOneThingAndOneDiscussion(wFlowFormDiscussionHistory);
        return restResult;
    }


    @PostMapping("/submitPurchasePlan")
    @ApiOperation(value = "提交|更新采购方案", notes = "提交|更新采购方案")
    public RestReturnResult submitPurchasePlan(@ApiParam(value = "保存提交采购方案入参", required = true) @RequestBody PurchasePlanParam purchasePlanParam) {
        RestReturnResult restResult = RestReturnResult.success();
        workFlowService.submitPurchasePlan(purchasePlanParam);
        return restResult;
    }

    @GetMapping("/changePurchasePlan/{wfLowFormId}")
    @ApiOperation(value = "变更采购方案", notes = "变更采购方案")
    public RestReturnResult changePurchasePlan(@ApiParam(value = "表单ID", required = true) @PathVariable("wfLowFormId") String wfLowFormId) {
        RestReturnResult restResult = RestReturnResult.success();
        workFlowService.changePurchasePlan(wfLowFormId);
        return restResult;
    }

    @PostMapping("/flowDown")
    @ApiOperation(value = "节点流转", notes = "节点流转")
    public RestReturnResult flowDown(@ApiParam(value = "节点流转入参", required = true) @RequestBody FlowTurnVO FlowTurnVO) {
        RestReturnResult restResult = RestReturnResult.success();
        workFlowService.FlowTurnCommon(FlowTurnVO);
        return restResult;
    }


//    @GetMapping("/sendBid/submit/{formId}")
//    @ApiOperation(value = "发标", notes = "发标")
//    public RestReturnResult sendBidSubmit(
//            @ApiParam(value="发标入参",required = true) @PathVariable String formId) {
//        RestReturnResult restResult = RestReturnResult.success();
//        workFlowService.sendBidSubmit(formId);
//        return restResult;
//    }


    @GetMapping("/abandonedBidList/{formId}")
    @ApiOperation(value = "废标列表数据", notes = "废标列表数据")
    public RestReturnResult<List<ExtWFlowFormBackBid>> abandonedBidList(@ApiParam(value = "表单ID", required = true) @PathVariable String formId) {
        RestReturnResult restResult = RestReturnResult.success();
        restResult.setData(workFlowService.selectAbandonedBidList(formId));
        return restResult;
    }

    @PostMapping("/abandonedBid")
    @ApiOperation(value = "废标", notes = "废标")
    public RestReturnResult<WFlowFormBidDelayHistory> abandonedBid(@ApiParam(value = "废标入参", required = true) @RequestBody SelectBidUnitReqVo selectBidUnitReqVo) {
        RestReturnResult restResult = RestReturnResult.success();
        workFlowService.abandonedBid(selectBidUnitReqVo);
        return restResult;
    }

    @PostMapping("/delayBid")
    @ApiOperation(value = "延标", notes = "延标")
    public RestReturnResult<WFlowFormBidDelayHistory> delayBid(@ApiParam(value = "延标入参", required = true) @RequestBody DelayBidVO delayBidVO) {
        RestReturnResult restResult = RestReturnResult.success();
        restResult.setData(workFlowService.delayBid(delayBidVO));
        return restResult;
    }

    @PostMapping("/delayBidHistory")
    @ApiOperation(value = "延标历史", notes = "延标历史")
    public RestReturnResult<List<WFlowFormBidDelayHistory>> delayBidHistory(@ApiParam(value = "延标历史入参", required = true) @RequestBody DelayBidVO delayBidVO) {
        RestReturnResult restResult = RestReturnResult.success();
        restResult.setData(workFlowService.delayBidHistory(delayBidVO));
        return restResult;
    }

    @GetMapping("/sendBidTwo/data")
    @ApiOperation(value = "二轮发标列表数据", notes = "二轮发标列表数据")
    public RestReturnResult<List<ExtWFlowFormBackBid>> sendBidTwoData(@ApiParam(value = "二轮发标列表查询入参", required = true) @RequestParam String flowFormId) {
        RestReturnResult restResult = RestReturnResult.success();
        restResult.setData(workFlowService.sendBidTwoData(flowFormId));
        return restResult;
    }


    @PostMapping("/sendBidTwo/submit")
    @ApiOperation(value = "提交二轮发标", notes = "提交二轮发标")
    public RestReturnResult sendBidTwoSubmit(
            @ApiParam(value = "提交二轮发标入参", required = true) @RequestBody SendBidTwoReqVO vo) {
        RestReturnResult restResult = RestReturnResult.success();
        workFlowService.sendBidTwoSubmit(vo);
        return restResult;
    }


    @GetMapping("/getBusinessBackBidInfoList")
    @ApiOperation(value = "商务谈判节点信息", notes = "商务谈判节点信息")
    public RestReturnResult<BackBidRspVO> getBusinessBackBidInfoList(@RequestParam String flowFormId) {
        RestReturnResult restResult = RestReturnResult.success();
        restResult.setData(workFlowService.selectBackBidNodeData(flowFormId, 3));
        return restResult;
    }

    @PostMapping("/initiateBusinessNegotiations/submit")
    @ApiOperation(value = "发起商务谈判", notes = "发起商务谈判")
    public RestReturnResult initiateBusinessNegotiations(
            @ApiParam(value = "发起商务谈判入参", required = true) @RequestBody BusinessBidReqVO businessBidReqVO) {
        RestReturnResult restResult = RestReturnResult.success();
        workFlowService.initiateBusinessNegotiations(businessBidReqVO);
        return restResult;
    }

    @GetMapping("/initiateBusinessNegotiations/data")
    @ApiOperation(value = "发起商务谈判数据", notes = "发起商务谈判数据")
    public RestReturnResult<BidEvaluationInterviewRspVO> initiateBusinessNegotiationsData(@ApiParam(value = "表单ID", required = true) @RequestParam String flowFormId) {
        RestReturnResult restResult = RestReturnResult.success();
        restResult.setData(workFlowService.bidEvaluationInterviewData(flowFormId));
        return restResult;
    }

    @PostMapping("/updateBusinessInfo")
    @ApiOperation(value = "商务谈判信息修改", notes = "商务谈判信息修改")
    public RestReturnResult updateBusinessInfo(@RequestBody ExtWFlowFormBackBid wFlowFormBackBid) {
        RestReturnResult restResult = RestReturnResult.success();
        workFlowService.updateBusinessInfo(wFlowFormBackBid);
        return restResult;
    }

    @GetMapping("/getBidEvaluationConclusion")
    @ApiOperation(value = "评标节点信息", notes = "评标节点信息")
    public RestReturnResult<BidEvaluationConclusionRspVO> getBidEvaluationConclusion(@ApiParam(value = "表单ID", required = true) @RequestParam String flowFormId) {
        RestReturnResult restResult = RestReturnResult.success();
        restResult.setData(workFlowService.getBidEvaluationConclusion(flowFormId));
        return restResult;
    }

    @GetMapping("/bidEvaluationInterview/data")
    @ApiOperation(value = "评标约谈列表数据", notes = "评标约谈列表数据")
    public RestReturnResult<BidEvaluationInterviewRspVO> bidEvaluationInterviewData(@ApiParam(value = "表单ID", required = true) @RequestParam String flowFormId) {
        RestReturnResult restResult = RestReturnResult.success();
        restResult.setData(workFlowService.bidEvaluationInterviewData(flowFormId));
        return restResult;
    }

    @PostMapping("/bidEvaluationInterview/submit")
    @ApiOperation(value = "提交评标约谈", notes = "提交评标约谈")
    public RestReturnResult bidEvaluationInterviewSubmit(@ApiParam(value = "评标约谈入参", required = true)
                                                         @RequestBody BidEvaluationInterviewReqVO vo) {
        RestReturnResult restResult = RestReturnResult.success();
        workFlowService.bidEvaluationInterviewSubmit(vo);
        return restResult;
    }

    @GetMapping("/getCalibrationInfoList")
    @ApiOperation(value = "定标信息汇总", notes = "定标信息汇总")
    public RestReturnResult<ConfirmBidNodeAllDataResVO> getCalibrationInfoList(
            @ApiParam(value = "表单ID", required = true) @RequestParam String flowFormId) {
        RestReturnResult restResult = RestReturnResult.success();
        ConfirmBidNodeAllDataResVO datas = workFlowService.selectConfirmBidNodeData(flowFormId);
        restResult.setData(datas);
        return restResult;
    }

    @PostMapping("/updateCalibrationInfo")
    @ApiOperation(value = "定标信息修改", notes = "定标信息修改")
    public RestReturnResult updateCalibrationInfo(@RequestBody ExtWFlowFormBackBid wFlowFormBackBid) {
        RestReturnResult restResult = RestReturnResult.success();
        workFlowService.updateCalibrationInfo(wFlowFormBackBid);
        return restResult;
    }


    @PostMapping("/addCalibrationInfo")
    @ApiOperation(value = "新增定标信息", notes = "新增定标信息")
    public RestReturnResult<List<CalibrationInfoRspVO>> addCalibrationInfo(@RequestBody CalibrationInfoReqVO calibrationInfoReqVO) {
        RestReturnResult restResult = RestReturnResult.success();
        restResult.setData(workFlowService.addCalibrationInfo(calibrationInfoReqVO));
        return restResult;
    }

    @PostMapping("/deleteCalibrationInfo")
    @ApiOperation(value = "删除定标信息", notes = "删除定标信息")
    public RestReturnResult deleteCalibrationInfo(@RequestBody CalibrationInfoReqVO calibrationInfoReqVO) {
        RestReturnResult restResult = RestReturnResult.success();
        workFlowService.deleteCalibrationInfo(calibrationInfoReqVO);
        return restResult;
    }

    @PostMapping("/saveCalibrationConclusion")
    @ApiOperation(value = "保存定标建议", notes = "保存定标建议")
    public RestReturnResult saveCalibrationConclusion(@RequestBody CalibrationInfoReqVO calibrationInfoReqVO) {
        RestReturnResult restResult = RestReturnResult.success();
        workFlowService.saveCalibrationConclusion(calibrationInfoReqVO);
        return restResult;
    }

    @GetMapping("/getAllSAttach")
    @ApiOperation(value = "附件历史", notes = "附件历史")
    public RestReturnResult<List<SAttachAllResVO>> getAllSAttach(@RequestParam String flowFormId) {
        RestReturnResult restResult = RestReturnResult.success();
        List<SAttachAllResVO> datas = workFlowService.selectAllSAttach(flowFormId);
        restResult.setData(datas);
        return restResult;
    }


    @GetMapping("/calibrationInterview/data/{formId}")
    @ApiOperation(value = "定标约谈数据", notes = "定标约谈数据")
    public RestReturnResult calibrationInterviewData(@PathVariable String formId) {
        RestReturnResult restResult = RestReturnResult.success();
        restResult.setData(workFlowService.selectCalibrationInterviewData(formId));
        return restResult;
    }

    @PostMapping("/calibrationInterview/submit")
    @ApiOperation(value = "提交定标约谈", notes = "提交定标约谈")
    public RestReturnResult calibrationInterviewSubmit(@RequestBody CalibrationInterviewVO vo) {
        RestReturnResult restResult = RestReturnResult.success();
        workFlowService.calibrationInterview(vo);
        return restResult;
    }

    @PostMapping("/calibrationApproval")
    @ApiOperation(value = "发起定标审批", notes = "发起定标审批")
    public RestReturnResult calibrationApproval(@RequestBody CalibrationApprovalVO vo) {
        return workFlowService.launchCalibrationApproval(vo);
    }

    @GetMapping("/sendNoticeAndThank")
    @ApiOperation(value = "发送中标通知书和感谢信", notes = "发送中标通知书和感谢信")
    public RestReturnResult sendNoticeAndThank(@RequestParam String formId) {
        RestReturnResult restResult = RestReturnResult.success();
        workFlowService.sendNoticeAndThank(formId);
        return restResult;
    }

    @GetMapping("/bidWinningNoticeList")
    @ApiOperation(value = "中标通知书", notes = "中标通知书")
    public RestReturnResult<BidWinningNoticeRspVO> bidWinningNoticeList(@RequestParam String formId) {
        RestReturnResult restResult = RestReturnResult.success();
        restResult.setData(workFlowService.bidWinningNoticeList(formId));
        return restResult;
    }


    @PostMapping("/quoteStrategicProtocol/data")
    @ApiOperation(value = "引用战略协议列表", notes = "引用战略协议列表")
    public RestReturnResult<List<ExtWStrategicProtocol>> getQuoteStrategicProtocolData(@RequestBody WStrategicProtocolReqVO wStrategicProtocolReqVO) {
        RestReturnResult restResult = RestReturnResult.success();
        restResult.setData(workFlowService.getQuoteStrategicProtocolList(wStrategicProtocolReqVO));
        return restResult;
    }


    @PostMapping("/quoteStrategicProtocol/submit")
    @ApiOperation(value = "提交引用战略协议", notes = "提交引用战略协议")
    public RestReturnResult<List<ExtWFlowFormStrategicProtocol>> quoteStrategicProtocol(@RequestBody QuoteStrategicProtocolVO quoteStrategicProtocolVO) {
        RestReturnResult restResult = RestReturnResult.success();
        restResult.setData(workFlowService.quoteStrategicProtocol(quoteStrategicProtocolVO));
        return restResult;
    }

    @PostMapping("/quoteStrategicProtocol/delete")
    @ApiOperation(value = "删除引用战略协议", notes = "删除引用战略协议")
    public RestReturnResult<List<ExtWFlowFormStrategicProtocol>> deleteQuoteStrategicProtocol(@RequestParam String id) {
        RestReturnResult restResult = RestReturnResult.success();
        workFlowService.deleteQuoteStrategicProtocol(id);
        return restResult;
    }

    @GetMapping("/quoteStrategicProtocol/updatePrice")
    @ApiOperation(value = "更新引用协议关联的价格", notes = "更新引用协议关联的价格")
    public RestReturnResult updatePrice(@RequestParam String id, @RequestParam Double price) {
        RestReturnResult restResult = RestReturnResult.success();
        workFlowService.updatePriceQuoteStrategicProtocol(id, price);
        return restResult;
    }


    @PostMapping("/quoteStrategicProtocol/list")
    @ApiOperation(value = "引用战略协议列表", notes = "引用战略协议列表")
    public RestReturnResult<List<ExtWStrategicProtocol>> quoteStrategicProtocolList(@RequestBody WStrategicProtocolReqVO wStrategicProtocolReqVO) {
        RestReturnResult restResult = RestReturnResult.success();
        Page<ExtWStrategicProtocol> page = new Page<>();
        page.setCurrent(wStrategicProtocolReqVO.getPageRequestVO().getPageNumber());
        page.setSize(wStrategicProtocolReqVO.getPageRequestVO().getPageSize());
        workFlowService.getQuoteStrategicProtocolPage(page, wStrategicProtocolReqVO);
        restResult.setData(page);
        return restResult;
    }

    @PostMapping("/uploadStrategicProtocol")
    public RestReturnResult uploadStrategicProtocol(HttpServletRequest request, HttpServletResponse response, HttpSession session) {
        RestReturnResult restResult = RestReturnResult.success();
        try {
            MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
            MultipartFile file = multipartRequest.getFile("upfile");
            if (file.isEmpty()) {
                throw new RuntimeException("文件不存在！", new ServiceThrowable());
            }
            InputStream in = file.getInputStream();
            restResult.setMsg(workFlowService.uploadStrategicProtocol(in));
            in.close();
        } catch (Exception e) {
            e.printStackTrace();
            restResult = RestReturnResult.error();
            restResult.setMsg(e.getMessage());
        }
        return restResult;
    }

    @PostMapping("/updateStrategicProtocol")
    public RestReturnResult updateStrategicProtocol(@RequestBody WStrategicProtocol wStrategicProtocol) throws Exception {
        RestReturnResult restResult = RestReturnResult.success();
        workFlowService.updateStrategicProtocol(wStrategicProtocol);
        return restResult;
    }

//    @GetMapping("/exportStrategicProtocol")
//    public void exportStrategicProtocol(HttpServletRequest request, HttpServletResponse response, HttpSession session) throws Exception{
//        String fileName = "新增合格供应商数量统计.xlsx";
//        WStrategicProtocolReqVO wStrategicProtocolReqVO = new WStrategicProtocolReqVO();
//        new ExportExcel("新增合格供应商数量统计", ExtWStrategicProtocol.class).
//                setDataList(workFlowService.getQuoteStrategicProtocolList(wStrategicProtocolReqVO))
//                .write(request,response, fileName).dispose();
//    }


    @GetMapping("/upload/form")
    public void form(HttpServletRequest request, HttpServletResponse response, HttpSession session) throws Exception {
        PrintWriter out = null;
        response.setCharacterEncoding("utf-8");  //防止ajax接受到的中文信息乱码
        response.setHeader("content-type", "text/html;charset=UTF-8");
        out = response.getWriter();
        out.print("<html><form action=\"/v1/formflow/uploadStrategicProtocol\" method=\"post\" enctype=\"multipart/form-data\">\n" +
                "     <input type=\"file\" class=\"file1\" name=\"upfile\" />\n" +
                "     <button type=\"submit\" class=\"but1\">上传</button>\n" +
                "</form></html>");
        out.flush();
        out.close();
    }


    @GetMapping("/selectBidUnitList")
    @ApiOperation(value = "选择中标供应商列表", notes = "选择中标供应商列表")
    public RestReturnResult<List<ExtWFlowFormBackBid>> selectBidUnitList(@RequestParam String formId) {
        RestReturnResult restResult = RestReturnResult.success();
        restResult.setData(workFlowService.selectBidUnitList(formId));
        return restResult;
    }

    @PostMapping("/selectBidUnit")
    @ApiOperation(value = "选择中标供应商", notes = "选择中标供应商")
    public RestReturnResult selectBidUnit(@RequestBody SelectBidUnitReqVo selectBidUnitReqVo) {
        RestReturnResult restResult = RestReturnResult.success();
        workFlowService.selectBidUnit(selectBidUnitReqVo);
        return restResult;
    }


    @GetMapping("/invitationDetail/{formId}")
    @ApiOperation(value = "邀请函详情", notes = "邀请函详情")
    public RestReturnResult<InvitationDetailResponse> invitationDetail(@PathVariable("formId") String formId) {
        RestReturnResult restResult = RestReturnResult.success();
        restResult.setData(workFlowService.invitationDetail(formId));
        return restResult;
    }


    @GetMapping("/questionAnswerNode/{flowId}")
    @ApiOperation(value = "答疑补遗节点数据", notes = "答疑/补遗")
    public RestReturnResult<AnswerQuestionResponseVO> getQuestionAnswer(@PathVariable String flowId) {
        RestReturnResult restResult = RestReturnResult.success();
        restResult.setData(workFlowService.getQuestionAnswerNodeData(flowId));
        return restResult;
    }

    @GetMapping("/answerList/{flowId}")
    @ApiOperation(value = "答疑", notes = "答疑/补遗")
    public RestReturnResult<AnswerNodeRspVO> getSuppliersQuestion(@PathVariable String flowId) {
        RestReturnResult restResult = RestReturnResult.success();
        restResult.setData(workFlowService.findAnswerNodeData(flowId));
        return restResult;
    }

    @GetMapping("/endumReferersList/{formId}")
    @ApiOperation(value = "补遗", notes = "答疑/补遗")
    public RestReturnResult<List<ExtWFlowFormAddendumReferers>> endumReferersList(@PathVariable("formId") String formId) {
        RestReturnResult restResult = RestReturnResult.success();
        restResult.setData(wFlowFormAddendumReferersService.findExtByFormId(formId));
        return restResult;
    }

    @PostMapping("/countSignList")
    @ApiOperation(value = "查看会签结果", notes = "答疑/补遗-补遗")
    public RestReturnResult<List<WFlowFormQaCountSign>> countSignList(@RequestBody WFlowFormQaCountSign wFlowFormQaCountSign) {
        RestReturnResult restResult = RestReturnResult.success();
        restResult.setData(wFlowFormQaCountSignService.selectByEntity(wFlowFormQaCountSign));
        return restResult;
    }

    @GetMapping("/addEndumReferers/{formId}")
    @ApiOperation(value = "新增补遗", notes = "答疑/补遗-补遗")
    public RestReturnResult<WFlowFormAddendumReferers> addEndumReferers(@PathVariable("formId") String formId) {
        RestReturnResult restResult = RestReturnResult.success();
        restResult.setData(wFlowFormAddendumReferersService.addByFormId(formId));
        return restResult;
    }

    @GetMapping("/deleteEndumReferers/{id}")
    @ApiOperation(value = "删除补遗", notes = "答疑/补遗-补遗")
    public RestReturnResult<Boolean> deleteEndumReferers(@PathVariable("id") String id) {
        RestReturnResult restResult = RestReturnResult.success();
        restResult.setData(wFlowFormAddendumReferersService.deleteById(id));
        return restResult;
    }

    @PostMapping("/qaCountSign")
    @ApiOperation(value = "发起会签", notes = "答疑/补遗")
    public RestReturnResult qaCountSign(@RequestBody QaCountSignReqVO qaCountSignReqVO) {
        RestReturnResult restResult = RestReturnResult.success();
        workFlowService.qaCountSign(qaCountSignReqVO);
        return restResult;
    }

    @GetMapping("/sendAskFile/{formId}")
    @ApiOperation(value = "发送答疑文件", notes = "答疑/补遗")
    public RestReturnResult sendAskFile(@PathVariable("formId") String formId) {
        RestReturnResult restResult = RestReturnResult.success();
        workFlowService.sendAskFile(formId);
        return restResult;
    }

    @GetMapping("/sendQuestionFile/{id}")
    @ApiOperation(value = "发送补遗文件", notes = "答疑/补遗")
    public RestReturnResult sendQuestionFile(@PathVariable("id") String id) {
        RestReturnResult restResult = RestReturnResult.success();
        workFlowService.sendQuestionFile(id);
        return restResult;
    }

    @PostMapping("/countSignResult")
    @ApiOperation(value = "提交会签结果", notes = "提交会签结果")
    public RestReturnResult countSignResult(@RequestBody DealRequestVO dealRequestVO) {
        RestReturnResult restResult = RestReturnResult.success();
        workFlowService.submitCountSignResult(dealRequestVO);
        return restResult;
    }

    @GetMapping("/openBidNodeData/{formId}")
    @ApiOperation(value = "开标节点数据", notes = "开标")
    public RestReturnResult<OpenBidRspVO> openBidNodeData(@PathVariable String formId) {
        RestReturnResult restResult = RestReturnResult.success();
        restResult.setData(workFlowService.selectOpenBidNodeData(formId));
        return restResult;
    }

    @GetMapping("/openBid/{formId}")
    @ApiOperation(value = "开标", notes = "开标")
    public RestReturnResult openBid(@PathVariable String formId) {
        RestReturnResult restResult = RestReturnResult.success();
        workFlowService.openBid(formId);
        return restResult;
    }

    @GetMapping("/inquiringBidNodeData/{formId}")
    @ApiOperation(value = "询标节点数据", notes = "询标节点数据")
    public RestReturnResult<InquiringBidRspVO> inquiringBidNodeData(@PathVariable String formId) {
        RestReturnResult restResult = RestReturnResult.success();
        restResult.setData(workFlowService.selectInquiringBidNodeData(formId));
        return restResult;
    }


    @GetMapping("/addInquiringBidAnswer/data/{formId}")
    @ApiOperation(value = "新增询标回复页面数据", notes = "新增询标回复页面数据")
    public RestReturnResult addInquiringBidAnswer(@PathVariable String formId) {
        RestReturnResult restResult = RestReturnResult.success();
        restResult.setData(workFlowService.selectAddInquiringBidAnswerData(formId));
        return restResult;
    }

    @PostMapping("/addInquiringBidAnswer/submit")
    @ApiOperation(value = "提交新增询标回复", notes = "提交新增询标回复")
    public RestReturnResult addInquiringBidAnswer(@RequestBody InquiringBidAnswerReqVO inquiringBidAnswerReqVO) {
        RestReturnResult restResult = RestReturnResult.success();
        workFlowService.addInquiringBidAnswer(inquiringBidAnswerReqVO);
        return restResult;
    }

    @GetMapping("/deleteInquiringBidAnswer/{id}")
    @ApiOperation(value = "删除询标回复", notes = "删除询标回复")
    public RestReturnResult deleteInquiringBidAnswer(@PathVariable String id) {
        RestReturnResult restResult = RestReturnResult.success();
        workFlowService.deleteInquiringBidAnswer(id);
        return restResult;
    }

    @GetMapping("/sendInquiringBidAnswer/{id}")
    @ApiOperation(value = "发送询标问卷", notes = "发送询标问卷")
    public RestReturnResult sendInquiringBidAnswer(@PathVariable String id) {
        RestReturnResult restResult = RestReturnResult.success();
        workFlowService.sendInquiringBidAnswer(id);
        return restResult;
    }

    @PostMapping("/initiatingTechnicalMarkScore")
    @ApiOperation(value = "发起技术标评分", notes = "发起技术标评分")
    public RestReturnResult initiatingTechnicalMarkScore(@RequestBody TechnicaBidScoreReqVO technicaBidScoreReqVO) {
        RestReturnResult restResult = RestReturnResult.success();
        workFlowService.initiatingTechnicalMarkScore(technicaBidScoreReqVO);
        return restResult;
    }


    @GetMapping("/flowBid")
    @ApiOperation(value = "流标", notes = "流标")
    public RestReturnResult<FlowBidRspVO> flowBid(
            @ApiParam(value = "发标入参", required = true) @RequestParam String formId) {
        RestReturnResult restResult = RestReturnResult.success();
        restResult.setData(workFlowService.flowBid(formId));
        return restResult;
    }

    @GetMapping("/technicalMarkScoreDetail/{formId}")
    @ApiOperation(value = "技术标打分待办详情", notes = "技术标打分待办详情")
    public RestReturnResult<InquiringBidRspVO> technicalMarkScoreDetail(@PathVariable String formId) {
        RestReturnResult restResult = RestReturnResult.success();
        restResult.setData(workFlowService.technicalMarkScoreDetail(formId));
        return restResult;
    }

    @PostMapping("/technicalMarkScoreSubmit")
    @ApiOperation(value = "技术标打分待办提交", notes = "技术标打分待办提交")
    public RestReturnResult<InquiringBidRspVO> technicalMarkScoreSubmit(@RequestBody TechnicalMarkScoreRspVO technicalMarkScoreRspVO) {
        RestReturnResult restResult = RestReturnResult.success();
        if (workFlowService.technicalMarkScoreSubmit(technicalMarkScoreRspVO)) {
            restResult = RestReturnResult.success();
        } else {
            restResult = RestReturnResult.error();
        }
        return restResult;
    }

    @GetMapping("/depositCashList")
    @ApiOperation(value = "保证金列表", notes = "保证金列表")
    public RestReturnResult<List<ExtWFlowFormCashDeposit>> depositCashList(@RequestParam String formId) {
        RestReturnResult restResult = RestReturnResult.success();
        restResult.setData(workFlowService.selectCashDeposit(formId));
        return restResult;
    }

    @GetMapping("/depositCashBack")
    @ApiOperation(value = "退保证金", notes = "退保证金")
    public RestReturnResult depositCashBack(@RequestParam String id) {
        RestReturnResult restResult = RestReturnResult.success();
        workFlowService.depositCashBack(id);
        return restResult;
    }

    @PostMapping("/addHistoryPrice")
    @ApiOperation(value = "新增历史价格水平", notes = "新增历史价格水平")
    public RestReturnResult addHistoryPrice(@RequestBody WFlowFormHistoryPrice wFlowFormHistoryPrice) {
        RestReturnResult restResult = RestReturnResult.success();

        restResult = wFlowFormHistoryPriceService.addHistoryPriceService(wFlowFormHistoryPrice);

        return restResult;
    }


    @GetMapping("/deleteHistoryPrice/{id}")
    @ApiOperation(value = "删除历史价格水平", notes = "删除历史价格水平")
    public RestReturnResult<String> deleteHistoryPrice(@PathVariable String id) {
        RestReturnResult restResult = RestReturnResult.error();
        try {
            WFlowFormHistoryPrice wFlowFormHistoryPrice = wFlowFormHistoryPriceService.selectById(id);
            if (wFlowFormHistoryPrice == null) {
                return new RestReturnResult(CommonConstants.FAIL, "数据不存在");
            }

            wFlowFormHistoryPrice.setBaseFeilds(UserUtils.getCurrentUserId(), null, CommonConstants.YES_INTEGER, false);
            boolean result = wFlowFormHistoryPriceService.updateById(wFlowFormHistoryPrice);
            if (result) {
                restResult = RestReturnResult.success();
            }
            restResult.setData(id);
        } catch (Exception e) {
            restResult = new RestReturnResult<Object>(CommonConstants.FAIL, id, CommonConstants.ERROR_CODES[0], e.getMessage());
        }
        return restResult;
    }

    @PostMapping("/addBidCandidateUnit")
    @ApiOperation(value = "新增投标候选单位", notes = "新增投标候选单位")
    public RestReturnResult<ExtWFlowFormBidCandidateUnit> addBidCandidateUnit(@RequestBody BidCandidateUnitReqResVO bidCandidateUnitRequestVO) {
        RestReturnResult restResult = RestReturnResult.success();
        restResult.setData(workFlowService.addBidCandidateUnit(bidCandidateUnitRequestVO));
        return restResult;
    }

    @GetMapping("/deleteBidCandidateUnit/{id}")
    @ApiOperation(value = "删除投标候选单位", notes = "删除投标候选单位")
    public RestReturnResult deleteBidCandidateUnit(@PathVariable String id) {
        RestReturnResult restResult = RestReturnResult.success();
        workFlowService.deleteBidCandidateUnit(id);
        return restResult;
    }

    @PostMapping("/addPurchaseTeam")
    @ApiOperation(value = "新增采购小组成员", notes = "新增采购小组成员")
    public RestReturnResult<WFlowFormPurchaseTeam> addPurchaseTeam(@RequestBody WFlowFormPurchaseTeam wFlowFormPurchaseTeam) {
        RestReturnResult restResult = RestReturnResult.error();
        try {
            wFlowFormPurchaseTeam.setBaseFeilds(UserUtils.getCurrentUserId(), null, 0, true);
            boolean result = wFlowFormPurchaseTeamService.insert(wFlowFormPurchaseTeam);
            if (result) {
                restResult = RestReturnResult.success();
            }
            restResult.setData(wFlowFormPurchaseTeam);
        } catch (Exception e) {
            restResult = new RestReturnResult<Object>(CommonConstants.FAIL, wFlowFormPurchaseTeam, CommonConstants.ERROR_CODES[0], e.getMessage());
        }
        return restResult;
    }

    @GetMapping("/deletePurchaseTeam/{id}")
    @ApiOperation(value = "删除采购小组成员", notes = "删除采购小组成员")
    public RestReturnResult<String> deletePurchaseTeam(@PathVariable String id) {
        RestReturnResult restResult = RestReturnResult.error();
        try {
            WFlowFormPurchaseTeam wFlowFormPurchaseTeam = wFlowFormPurchaseTeamService.selectById(id);
            if (wFlowFormPurchaseTeam == null) {
                return new RestReturnResult(CommonConstants.FAIL, "数据不存在");
            }

            wFlowFormPurchaseTeam.setBaseFeilds(UserUtils.getCurrentUserId(), null, CommonConstants.YES_INTEGER, false);
            boolean result = wFlowFormPurchaseTeamService.updateById(wFlowFormPurchaseTeam);
            if (result) {
                restResult = RestReturnResult.success();
            }
            restResult.setData(id);
        } catch (Exception e) {
            restResult = new RestReturnResult<Object>(CommonConstants.FAIL, id, CommonConstants.ERROR_CODES[0], e.getMessage());
        }
        return restResult;
    }

    @PostMapping("/addSAttachment")
    @ApiOperation(value = "新增采购附件", notes = "新增采购附件")
    public RestReturnResult addSAttachment(@RequestBody SAttachment sAttachment) {
        RestReturnResult restResult = RestReturnResult.error();
        try {
            boolean result = false;
            SessionUserVo sessionUserVo = UserUtils.getCurrentUserVo();
            sAttachment.setCreateByUsername(sessionUserVo.getRealName());
            sAttachment.setUpdateByUsername(sessionUserVo.getRealName());
            if (StringUtils.isEmpty(sAttachment.getId())) {
                sAttachment.setBaseFeilds(UserUtils.getCurrentUserId(), null, 0, true);
                result = sAttachmentService.insert(sAttachment);
            } else {
                sAttachment.setUpdateDate(DateUtils.getNow());
                result = sAttachmentService.updateById(sAttachment);
            }

            if (result) {
                restResult = RestReturnResult.success();
            }
            restResult.setData(sAttachment);
        } catch (Exception e) {
            e.printStackTrace();
            restResult = new RestReturnResult<Object>(CommonConstants.FAIL, sAttachment, CommonConstants.ERROR_CODES[0], e.getMessage());
        }
        return restResult;
    }

    @PostMapping("/getSAttachment")
    @ApiOperation(value = "获取采购附件", notes = "获取采购附件")
    public RestReturnResult getSAttachment(@RequestBody SAttachment sAttachment) {
        RestReturnResult restResult = RestReturnResult.success();
        restResult.setData(sAttachmentService.getOneByEntity(sAttachment));
        return restResult;
    }

    @GetMapping("/deleteSAttachment/{id}")
    @ApiOperation(value = "删除采购附件", notes = "删除采购附件")
    public RestReturnResult deleteSAttachment(@PathVariable String id) {
        RestReturnResult restResult = RestReturnResult.error();
        try {
            SAttachment sAttachment = sAttachmentService.selectById(id);
            if (sAttachment == null) {
                return new RestReturnResult(CommonConstants.FAIL, "数据不存在");
            }

            sAttachment.setBaseFeilds(UserUtils.getCurrentUserId(), null, CommonConstants.YES_INTEGER, false);
            boolean result = sAttachmentService.updateById(sAttachment);
            if (result) {
                restResult = RestReturnResult.success();
            }
            restResult.setData(id);
        } catch (Exception e) {
            restResult = new RestReturnResult<Object>(CommonConstants.FAIL, id, CommonConstants.ERROR_CODES[0], e.getMessage());
        }
        return restResult;
    }

//    @PostMapping("/savePurchasePlan")
//    @ApiOperation(value = "保存采购方案", notes = "保存采购方案")
//    public RestReturnResult savePurchasePlan(@RequestBody PurchasePlanRequestVO purchasePlanRequestVO) {
//        RestReturnResult restResult = RestReturnResult.success();
//        workFlowService.savePurchasePlan(purchasePlanRequestVO);
//        return restResult;
//    }


    @GetMapping("/lstSupplierEntry/{myDealId}")
    @ApiOperation(value = "获取入围供应商列表(待办入口)", notes = "列表信息", httpMethod = "GET")
    public RestReturnResult lstSupplierEntry(@PathVariable("myDealId") String formId) {
        RestReturnResult restResult = RestReturnResult.error();

        try {
            restResult = workFlowService.lstSupplierEntry(formId);
        } catch (Exception e) {
            e.printStackTrace();
            restResult = new RestReturnResult<Object>(CommonConstants.FAIL, formId, CommonConstants.ERROR_CODES[0], CommonConstants.ERROR_DESCS[0]);
        }

        return restResult;
    }

    @GetMapping("/launchDepositConfirm/{flowFormId}")
    @ApiOperation(value = "发起保证金确认", notes = "发起保证金确认", httpMethod = "GET")
    public RestReturnResult launchDepositConfirm(@PathVariable("flowFormId") String flowFormId) {
        RestReturnResult restResult = RestReturnResult.error();

        try {
            restResult = workFlowService.launchDepositConfirm(flowFormId);
        } catch (Exception e) {
            e.printStackTrace();
            restResult = new RestReturnResult<Object>(CommonConstants.FAIL, flowFormId, CommonConstants.ERROR_CODES[0], CommonConstants.ERROR_DESCS[0]);
        }

        return restResult;
    }


    @PostMapping("/depositConfirm")
    @ApiOperation(value = "保证金确认", notes = "保证金确认", httpMethod = "POST")
    public RestReturnResult depositConfirm(@RequestBody DepositConfirmRequestVO depositConfirmRequestVO) {
        RestReturnResult restResult = RestReturnResult.error();

        try {
            restResult = workFlowService.depositConfirm(depositConfirmRequestVO);
        } catch (Exception e) {
            e.printStackTrace();
            restResult = new RestReturnResult<Object>(CommonConstants.FAIL, CommonConstants.ERROR_CODES[0], CommonConstants.ERROR_DESCS[0]);
        }

        return restResult;
    }

    @GetMapping("/biddingAnnouncement/{flowFormId}")
    @ApiOperation(value = "招标公告", notes = "招标公告", httpMethod = "GET")
    public RestReturnResult biddingAnnouncement(@PathVariable("flowFormId") String flowFormId) {
        RestReturnResult restResult = RestReturnResult.error();

        try {
            restResult = workFlowService.biddingAnnouncement(flowFormId);
        } catch (Exception e) {
            e.printStackTrace();
            restResult = new RestReturnResult<Object>(CommonConstants.FAIL, CommonConstants.ERROR_CODES[0], CommonConstants.ERROR_DESCS[0]);
        }

        return restResult;
    }

    @PostMapping("/sendBiddingAnnoucement")
    @ApiOperation(value = "发送招标公告", notes = "招标公告", httpMethod = "POST")
    public RestReturnResult sendBiddingAnnoucement(@RequestBody BiddingAnnouncementRequestVO biddingAnnouncementRequestVO) {
        RestReturnResult restResult = RestReturnResult.error();

        restResult = workFlowService.sendBiddingAnnoucement(biddingAnnouncementRequestVO);

        return restResult;
    }

    @GetMapping("/biddingDocument/{flowFormId}")
    @ApiOperation(value = "招标文件详情", notes = "招标文件", httpMethod = "GET")
    public RestReturnResult biddingDocument(@PathVariable("flowFormId") String flowFormId) {
        RestReturnResult restResult = RestReturnResult.error();

        try {
            restResult = workFlowService.biddingDocument(flowFormId);
        } catch (Exception e) {
            e.printStackTrace();
            restResult = new RestReturnResult<Object>(CommonConstants.FAIL, CommonConstants.ERROR_CODES[0], CommonConstants.ERROR_DESCS[0]);
        }

        return restResult;
    }

    @PostMapping("/biddingDocumentOperation")
    @ApiOperation(value = "招标文件操作", notes = "招标文件", httpMethod = "POST")
    public RestReturnResult biddingDocumentOperation(@RequestBody BiddingDocumentRequestVO biddingDocumentRequestVO) {
        RestReturnResult restResult = RestReturnResult.error();
        restResult = workFlowService.biddingDocumentOperation(biddingDocumentRequestVO);
        return restResult;
    }

    @GetMapping("/sendBiddingDetails/{flowFormId}")
    @ApiOperation(value = "发标详情", notes = "发标", httpMethod = "GET")
    public RestReturnResult sendBiddingDetails(@PathVariable("flowFormId") String flowFormId) {
        RestReturnResult restResult = RestReturnResult.error();

        try {
            restResult = workFlowService.sendBiddingDetails(flowFormId);
        } catch (Exception e) {
            e.printStackTrace();
            restResult = new RestReturnResult<Object>(CommonConstants.FAIL, CommonConstants.ERROR_CODES[0], CommonConstants.ERROR_DESCS[0]);
        }

        return restResult;
    }

    @PostMapping("/updateTimeNodePlan")
    @ApiOperation(value = "修改时间节点计划", notes = "招标文件", httpMethod = "POST")
    public RestReturnResult updateTimeNodePlan(@RequestBody TimeNodePlanVO timeNodePlanVO) {
        RestReturnResult restResult = RestReturnResult.error();

        try {
            restResult = workFlowService.updateTimeNodePlan(timeNodePlanVO);
        } catch (Exception e) {
            e.printStackTrace();
            restResult = new RestReturnResult<Object>(CommonConstants.FAIL, CommonConstants.ERROR_CODES[0], CommonConstants.ERROR_DESCS[0]);
        }
        return restResult;
    }

    @PostMapping("/sendIntraNotification")
    @ApiOperation(value = "发送内部通知", notes = "采购方案", httpMethod = "POST")
    public RestReturnResult sendIntraNotification(@RequestBody IntraNotificationRequestVO vo) {
        RestReturnResult restResult = RestReturnResult.success();

        restResult = workFlowService.sendIntraNotification(vo);

        return restResult;
    }

    @PostMapping("/getCompanyList")
    @ApiOperation(value = "获取公司列表", notes = "获取公司列表", httpMethod = "POST")
    public RestReturnResult getCompanyList() {
        RestReturnResult restResult = RestReturnResult.success();
        SCompany sCompany = new SCompany();
        sCompany.setDelFlag(CommonConstants.NO_INTEGER);
        EntityWrapper wrapper = new EntityWrapper();
        wrapper.setEntity(sCompany);
        restResult.setData(sCompanyService.selectList(wrapper));
        return restResult;
    }

    /*@PostMapping("/confirmDepositCallBack")
    @ApiOperation(value = "MBS出纳确认收保证金回调", notes = "MBS出纳确认收保证金回调", httpMethod = "POST")
    public RestReturnResult confirmDepositCallBack(@RequestBody List<ConfirmDepositCallBackReqVO> confirmDepositCallBackReqVOList){
    	RestReturnResult restResult = RestReturnResult.success();

    	restResult = workFlowService.confirmDepositCallBack(confirmDepositCallBackReqVOList);

    	return restResult;
    }

    @PostMapping("/drawBackDepositCallBack")
    @ApiOperation(value = "MBS出纳确认退保证金回调", notes = "MBS出纳确认退保证金回调", httpMethod = "POST")
    public RestReturnResult drawBackDepositCallBack(@RequestBody List<DrawBackDepositCallBackReqVO> drawBackDepositCallBackReqVOList){
    	RestReturnResult restResult = RestReturnResult.success();

    	restResult = workFlowService.drawBackDepositCallBack(drawBackDepositCallBackReqVOList);

    	return restResult;
    }*/

    @PostMapping("/mbsCommonCallBack")
    @ApiOperation(value = "MBS回调公共接口", notes = "MBS回调公共接口", httpMethod = "POST")
    public RestReturnResult mbsCommonCallBack(@RequestBody List<MbsCommonCallBackReqVO> mbsCommonCallBackReqVOList) {
        RestReturnResult restResult = RestReturnResult.success();
        try {
            restResult = workFlowService.mbsCommonCallBack(mbsCommonCallBackReqVOList);
        } catch (Exception e) {
            e.printStackTrace();
            restResult = new RestReturnResult<Object>(CommonConstants.FAIL, CommonConstants.ERROR_CODES[0], CommonConstants.ERROR_DESCS[0]);
        }
        return restResult;
    }

//    @Autowired
//    public RedisDBHelper redisDBHelper;
//    @PostMapping("/gg")
//    public RestReturnResult gg(){
//        System.out.println(redisDBHelper.lock("12345","1","NX","PX",20));
//        return null;
//    }


    @PostMapping("/updateOperator")
    @ApiOperation(
            value = "更新经办人",
            notes = "更新经办人"
    )
    public RestReturnResult updateOperator(@RequestBody UpdateOperatorVO updateOperatorVO) {
        RestReturnResult restResult = RestReturnResult.success();
        workFlowService.updateOperator(updateOperatorVO);
        return restResult;
    }

    @GetMapping("/getJumpNode/{id}")
    @ApiOperation(
            value = "获取当前需要跳转的节点",
            notes = "获取当前需要跳转的节点"
    )
    public RestReturnResult updateOperator(@PathVariable String id) {
        RestReturnResult restResult = RestReturnResult.success();
        WFlowForm w = wFlowFormService.selectById(id);
        String status = w.getFlowFormSubStatus();
        if (!status.equals("99")) {
            if (status.contains(",")) {
                status = status.split(",")[0];
            }
        } else {
            status = null;
        }
        restResult.setData(status);
        return restResult;
    }
}
